Skip to content

HDDS-15342. Make RocksDB bottommost level compaction options configurable for background compaction#10419

Open
ptlrs wants to merge 11 commits into
apache:masterfrom
ptlrs:HDDS-15342-Make-RocksDB-BottommostLevelCompaction-options-configurable
Open

HDDS-15342. Make RocksDB bottommost level compaction options configurable for background compaction#10419
ptlrs wants to merge 11 commits into
apache:masterfrom
ptlrs:HDDS-15342-Make-RocksDB-BottommostLevelCompaction-options-configurable

Conversation

@ptlrs

@ptlrs ptlrs commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

RocksDB allows multiple configurations for configuration the compaction strategy for the bottom-most layer. These configurations impact the compaction times.

This PR makes the compaction strategy configurable.

  • Adds a config for setting the compaction strategy
  • Sets the default strategy to kSkip which is faster than kForce
  • Adds tests

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15342

How was this patch tested?

CI: https://github.com/ptlrs/ozone/actions/runs/26857346964

Comment thread hadoop-hdds/common/src/main/resources/ozone-default.xml Outdated

@sarvekshayr sarvekshayr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ptlrs for working on this.

@sarvekshayr sarvekshayr marked this pull request as ready for review June 10, 2026 05:20
@sarvekshayr

sarvekshayr commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Failed acceptance (tools) CI - CompactOMDB defaults to kSkip which does not reduce the OM DB size in this test. #10428 should fix this test by passing the compaction type as kForce and be merged first.

Compact OM DB Column Family
    [Arguments]        ${column_family}
    Execute    ozone repair om compact --cf=${column_family} --service-id ${OM_SERVICE_ID} --node-id om1 --blc 2

Comment thread hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java Outdated
Comment thread hadoop-hdds/common/src/main/resources/ozone-default.xml Outdated

@ashishkumar50 ashishkumar50 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ptlrs Thanks for the update, LGTM.

@ashishkumar50

Copy link
Copy Markdown
Contributor

@ptlrs Can you please look at test failure, looks related.

@ptlrs

ptlrs commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@ashishkumar50 as @sarvekshayr had also observed, this PR depends on #10428 which fixes the failing Robot test.

Can we please merge that first? I may need to pull the changes in this PR after that.

ptlrs added 2 commits June 17, 2026 10:23
…ocksDB-BottommostLevelCompaction-options-configurable

# Conflicts:
#	hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/CompactDBUtil.java
#	hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/CompactionService.java
@ptlrs

ptlrs commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Hi @ashishkumar50 @sarvekshayr, could you please take another look? I have merged the changes from master. The robot test should now pass.

Comment thread hadoop-hdds/common/src/main/resources/ozone-default.xml Outdated
</description>
</property>
<property>
<name>ozone.om.compaction.service.bottommostlevelcompaction</name>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use - as separator in last part of the property name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? bottommostlevelcompaction is the original name as per org.rocksdb.CompactRangeOptions.BottommostLevelCompaction.

Most importantly, searching for bottommostlevelcompaction brings up all instances of it in both code and configuration in my IDE. Adding a separator would break that.

@adoroszlai adoroszlai Jul 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BottommostLevelCompaction uses CamelCase. The same with lower case needs some separator, e.g. - (kebab-case) or _ (snake_case) for readability. In config property names - is commonly used.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

This PR has been marked as stale due to 21 days of inactivity. Please comment or remove the stale label to keep it open. Otherwise, it will be automatically closed in 7 days.

@github-actions github-actions Bot added the stale label Jul 9, 2026
@sarvekshayr

Copy link
Copy Markdown
Contributor

@ptlrs Could you please drive this PR to completion by addressing the minor comments given?

@github-actions github-actions Bot removed the stale label Jul 10, 2026
…ocksDB-BottommostLevelCompaction-options-configurable
@ptlrs ptlrs requested a review from adoroszlai July 13, 2026 22:56
…BottommostLevelCompaction configuration values.

@sarvekshayr sarvekshayr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the patch @ptlrs.

  • Please look into the CI build failure.

  • Let's update compaction CLI to also use enum names instead of int - #10428
    It can also be done in a follow-up PR.

Comment thread hadoop-hdds/common/src/main/resources/ozone-default.xml Outdated
Comment thread hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java Outdated
…on with enum and update configuration handling.
@ptlrs ptlrs requested a review from sarvekshayr July 16, 2026 04:10

@ptlrs ptlrs left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the CLIs to use the enum directly instead of ints or strings.

${COMPLETION-CANDIDATES} will render the valid values automatically.

bash-5.1$ ozone repair om compact -h                 
Usage: ozone repair om compact [-hV] [--dry-run] [--force] [--verbose]
                               [--blc=<bottommostLevelCompaction>]
                               --cf=<columnFamilyName> [--node-id=<nodeId>]
                               [--service-id=<omServiceId>]
CLI to compact a column family in the om.db. The compaction happens
asynchronously. Requires admin privileges. OM should be running for this tool.
      --blc, --bottommost-level-compaction=<bottommostLevelCompaction>
                           BottommostLevelCompaction option for RocksDB
                             compaction.  Valid values: kSkip,
                             kIfHaveCompactionFilter, kForce, kForceOptimized
                             Default: kSkip
      --cf, --column-family=<columnFamilyName>
bash-5.1$ ozone repair om compact --cf keyTable --blc test1
Invalid value for option '--bottommost-level-compaction': expected one of [kSkip, kIfHaveCompactionFilter, kForce, kForceOptimized] (case-sensitive) but was 'test1'
Usage: ozone repair om compact [-hV] [--dry-run] [--force] [--verbose]

Also, the maven verify command is incorrectly flagging an unused dependency. It only sees the transitive dependency's usage as per the bytecode and ignores the parent dependency's direct usage.

Comment thread hadoop-ozone/common/pom.xml Outdated
Comment on lines +243 to +248
<!--
OMConfigKeys references ManagedCompactRangeOptions.BottommostLevelCompaction, an enum
inherited from org.rocksdb.CompactRangeOptions. Bytecode resolves it to the rocksdb
class, so the analyzer does not see the hdds-managed-rocksdb reference.
-->
<ignoredUnusedDeclaredDependency>org.apache.ozone:hdds-managed-rocksdb:jar</ignoredUnusedDeclaredDependency>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ptlrs for updating the patch.

Also, the maven verify command is incorrectly flagging an unused dependency. It only sees the transitive dependency's usage as per the bytecode and ignores the parent dependency's direct usage.

A better way to fix it is:

  • allow usage of CompactRangeOptions.BottommostLevelCompaction, since it's just an enum, safe to use directly:

    ozone/pom.xml

    Lines 1967 to 1969 in 1a94394

    <!-- Allow non-RocksObject classes. -->
    <allowedImport>org.rocksdb.ColumnFamilyDescriptor</allowedImport>
    <allowedImport>org.rocksdb.CompactionStyle</allowedImport>
  • import and use CompactRangeOptions.BottommostLevelCompaction (in OMConfigKeys and elsewhere) instead of ManagedCompactRangeOptions.BottommostLevelCompaction
  • remove unused dependency hdds-managed-rocksdb from hadoop-ozone/common/pom.xml

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion @adoroszlai. I have updated the PR.

@ptlrs ptlrs requested a review from adoroszlai July 16, 2026 17:58
Comment thread pom.xml
<allowedImports>
<!-- Allow non-RocksObject classes. -->
<allowedImport>org.rocksdb.ColumnFamilyDescriptor</allowedImport>
<allowedImport>org.rocksdb.CompactRangeOptions</allowedImport>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for nitpicking: CompactRangeOptions extends RocksObject, so it should not be allowed, only CompactRangeOptions.BottommostLevelCompaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants